/* Hawk - An OSGI Based Test Framework
 *
 * Copyright (C) 2010 http://code.google.com/p/hawk-framework/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 */
package org.hawk.gui.activator;

import org.osgi.framework.BundleContext;

/**
 * This is a singleton class responsible to store the OGSI context inside the 
 * Hawk Test Framework interface system  
 *  
 * @author Rodrigo Prestes Machado
 * @version November 15, 2009
 */
public class OsgiContext {

	/** The unique instance of OsgiContext class */
	private static OsgiContext instance;
	/** OSGI context */
	private BundleContext context;
	
	/** It Keeps the constructor private because of the singleton */
	private OsgiContext(){}
	
	/**
	 * Method used to return the unique instance of OsgiContext. The instance 
	 * has one reference to a BundleContext object. So, you can use the 
	 * getContext() method to retrieve the OSGI context.
	 * 
	 * @return Returns the unique instance of OsgiContext class
	 */
	public static OsgiContext getInstance() {	
		if (instance == null)
			instance = new OsgiContext();
		return instance;
	}
	
	/**
	 * Returns the OGSI context
	 * 
	 * @return One reference to OSGI context 
	 */
	public BundleContext getContext() {
		return context;
	}

	/**
	 * Method responsible to store the OSGI context inside the singleton  
	 * 
	 * @param A BundleContext instance (OSGI context)
	 */
	public void setContext(BundleContext context) {
		this.context = context;
	}
}
